import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams ,ViewController} from 'ionic-angular';
import { HttpProvider } from '../../providers/http/http';
import { StorageProvider } from '../../providers/storage/storage';
import { DialogProvider } from '../../providers/dialog/dialog';
import { DomSanitizer } from '@angular/platform-browser';

/**
 * Generated class for the UserAgreementPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
  selector: 'page-user-agreement',
  templateUrl: 'user-agreement.html',
})
export class UserAgreementPage {

  public data = [
    {img:null,
     titles:null,
     summary:null,
     description:null}
    ];
  constructor(
		public navCtrl: NavController,
		public viewCtrl: ViewController,
		public navParams: NavParams,
		public http: HttpProvider,
		public storage: StorageProvider,
    public dialog: DialogProvider,
  	private sanitizer: DomSanitizer) {
		}


    ionViewDidLoad() {
      this.agreement();
      console.log('ionViewDidLoad HelpPage');
    }
  
  
    assembleHTML(strHTML:any) {
    return this.sanitizer.bypassSecurityTrustHtml(strHTML);
    }
  
    agreement() {
      
      this.http.postJson('', 'users/member/useprotocol', 
           {
            "tables":"5",                 
            "file_type_id":"8",
            "soft_wen_type":"2",
            "limit":"10",
            "page":"1",
            "where":["=","is_display","1"]
           }, '').then(res => {
           console.log(res)
        if(res['status'] == 200) {
        this.getMessage(res['data']);
        }
      });
      
    }
    getMessage(data) {
      this.data.splice(0);
      console.log(data)
      for (let message of data) {
        if (message) {
          var a = {
            /*根据提供的接口地址传参数,配置文件在http.ts里查看,里面写的是链接服务器的配置*/
              img:  this.http.APP_IMG+message.url,
              titles : message.titles,
              summary : message.summary,
              description: message.description
          };
          this.data.push(a);
        }
      }
      console.log(this.data);
     }
  }
  



